<?php
/**
 * Created by PhpStorm.
 * User: yaosj
 * Date: 15-10-12
 * Time: 下午4:21
 */

class GetCollectedCareer implements iController
{

    public function output($queryArgs) {

        if (validateUser($queryArgs) != 1)
            return genOutput(1000);
        global $uddb;
        $sql = 'SELECT m.id uniq_code,m.department_job_code,m.job_title,m.department_name,m.personnel_officer,m.enrollment_num,m.exist_num FROM user_job_collection u,educms.data_job_major m WHERE u.user_id = :user_id AND u.department_job_code = m.id AND u.status = 1';
        //当前年份
        $returnV = require __DIR__ . '/code2name.config.php';
        $curYear = $returnV['current_year'];
        if (isset($curYear))
            $sql .= " AND m.major_year = {$curYear} ";
        $a = $uddb -> getResults($sql,array(':user_id'=>$queryArgs['user_id']));

        $updatedHour = getdate(time())['hours'];
        if ($updatedHour < 10)
            $uTime = $date = date('Y-m-d' ,strtotime('-1 day')).' 15:30';
        else if ($updatedHour >= 16)
            $uTime = $date = date('Y-m-d',time()).' 15:30';
        else
            $uTime = $date = date('Y-m-d',time()).' 09:00';

        return genOutput(1,array('count' => count($a),'updated_time' => $uTime,'data' => $a));
    }
}